local skel = fk.CreateSkill {
  name = "emo__mingjian",
}

skel:addEffect(fk.CardUsing, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and data.card.is_damage_card and not player:isNude()
  end,
  on_cost = function(self, event, target, player, data)
    local ids = table.filter(player:getCardIds("he"), function (id)
      local c = Fk:getCardById(id)
      return not player:prohibitDiscard(c) and not c.is_damage_card
    end)
    local cards = player.room:askToDiscard(player, {
      max_num = 1, min_num = 1, include_equip = true, skill_name = skel.name, pattern = tostring(Exppattern{ id = ids }),
      prompt = "#emo__mingjian-invoke:::"..data.card:toLogString(), skip = true,
    })
    if #cards > 0 then
      event:setCostData(self, { cards = cards })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    player.room:throwCard(event:getCostData(self).cards, skel.name, player, player)
    data.additionalEffect = (data.additionalEffect or 0) + 1
  end,
})

Fk:loadTranslationTable{
  ["emo__mingjian"] = "暝剑",
  [":emo__mingjian"] = "当你使用伤害牌时，你可以弃置一张非伤害牌，令此牌额外结算一次。",

  ["#emo__mingjian-invoke"] = "暝剑：你可以弃置一张非伤害牌，令%arg额外结算一次",
}


return skel
